---
category: String
created: '2021-11-11'
title: Convert a base64 encoded string to an uint8 array
---

**JavaScript version**

```js base64ToUint8.js
const base64ToUint8 = (str) => Uint8Array.from(atob(str), (c) => c.charCodeAt(0));
```

**TypeScript version**

```ts base64ToUint8.ts
const base64ToUint8 = (str: string): Uint8Array => Uint8Array.from(atob(str), (c) => c.charCodeAt(0));
```

## See also

-   [Convert an uint8 array to a base64 encoded string](https://phuoc.ng/collection/1-loc/convert-an-uint8-array-to-a-base64-encoded-string/)
